!function(e){!function(e){"use strict";var t,i,r,n,o,a,s,d,c,l,u,g,p,v,m=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)},h=(e,t,i)=>(m(e,t,"read from private field"),i?i.call(e):t.get(e)),w=(e,t,i)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,i)},y=(e,t,i,r)=>(m(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i),f=(e,t,i)=>(m(e,t,"access private method"),i),I=(e=>(e["SetDomain"]="setDomain",e["SetListToken"]="setListToken",e["SetUserId"]="setUserId",e["SetEvent"]="setEvent",e["SetCookie"]="setCookie",e["SetAutoFunnelData"]="setAutoFunnelData",e["Push"]="push",e["SetCustomServiceWorkerPath"]="setCustomSwPath",e["ViewItem"]="viewItem",e["ViewCategory"]="viewCategory",e["LikeItem"]="likeItem",e["UnlikeItem"]="unlikeItem",e["WishListItem"]="wishlistItem",e["Purchase"]="orderPlaced",e["CartUpdate"]="cartUpdate",e["ShopifyAbandonedCart"]="shopifyAbandonedCart",e["SaveEvent"]="saveEvent",e["FlushEvents"]="flushEvents",e["SetUserDevice"]="setUserDevice",e["SetUserLocation"]="setUserLocation",e["SetVisitUrlPath"]="setVisitUrlPath",e["SetLastActivityDate"]="setLastActivityDate",e["SetIsNewVisitor"]="setIsNewVisitor",e["SetHasUserVisitPage"]="setHasUserVisitPage",e["SetRawEvent"]="setRawEvent",e["ImportScript"]="importScript",e["DelayScript"]="delayScript",e["InitScript"]="initScript",e))(I||{});(v=p||(p={}))["PageVisit"]="visit",v["Popup"]="popup",v["ViewItem"]="view_item",v["ViewCategory"]="view_category",v["WishlistItem"]="wishlist_item",v["LikeItem"]="like_item",v["UnlikeItem"]="unlike_item",v["OrderPlaced"]="order_placed",v["Cart"]="cart_update",void(v["ShopifyAbandonedCart"]="shopify_webhook_abandoned_cart");class C extends Error{constructor(e){super(e),Object.setPrototypeOf(this,new.target.prototype),this.name=this.constructor.name}}class b extends C{constructor(e){super(e)}}const E={cartToken:"string",urlToken:"string",visitorEmail:"string"},S=["cartToken","urlToken"];var P,_,D,T,V,k,A,O,U;(U=P||(P={}))["Inline"]="inline",void(U["Popup"]="popup"),(O=_||(_={}))["Hq"]="Hq",void(O["Us"]="Us"),void((D||(D={}))["UserAid"]="X-Aid"),(A=T||(T={}))["Active"]="active",void(A["Inactive"]="inactive"),(k=V||(V={}))["ReactSendWebPush"]="react_web_webpush",k["ReactCollectWebPushConsent"]="react_web_collect_webpush_subscription",k["ReactShowPopup"]="react_web_popup",k["FilterWebUrl"]="filter_web_url",k["FilterWebSubscribers"]="filter_web_subscriber",k["FilterLocation"]="filter_web_geolocation",k["FilterDevice"]="filter_web_device",k["FilterReturningVisitor"]="filter_web_returning_visitor",k["ConditionProductViewed"]="await_web_view_item_event",k["ConditionCategoryViewed"]="await_web_view_category_event",k["ConditionWebPushConsent"]="await_web_webpush_subscribe",k["ConditionProductLiked"]="await_web_like_item_event",k["TransferToBackend"]="react_backend_transfer",k["AwaitScroll"]="await_scroll",void(k["ShowPopup"]="react_popup");var L=(e=>(e["UuidHasBeenSet"]="grUuidHasBeenSet",e["PopupsRendererCustomUrl"]="grPopupsRendererCustomUrl",e))(L||{});const N="_grDebugMode",x=new class{isDebugEnabled(){return!!window.sessionStorage.getItem(N)}startDebug(){window.sessionStorage.setItem(N,"true")}},F=new class{get isLoggingEnabled(){return x.isDebugEnabled()}log(...e){this.displayLog("log",...e)}info(...e){this.displayLog("info",...e)}error(...e){if(e[0]instanceof Error)e.push(e[0].stack);this.displayLog("error",...e)}warn(...e){this.displayLog("warn",...e)}displayLog(e,...t){if(this.isLoggingEnabled)console[e](...t)}};class W{constructor(){w(this,t,new Proxy({},{get(e,t){if(t in e)return e[t];else return e[t]=[],e[t]}}))}addEvent(e,i){h(this,t)[e].push(i)}drainEvents(e){const i=h(this,t)[e];return h(this,t)[e]=[],i}getEvents(e){return h(this,t)[e]}hasDelayedEvents(e){return h(this,t)[e].length>0}}t=new WeakMap,i=new WeakMap,r=new WeakMap;const R=new class{constructor(){w(this,i,{}),w(this,r,new W)}publish(e,...t){var n;if(null==(n=h(this,i)[e])?void 0:n.length)h(this,i)[e].forEach((i=>{i(...t),F.log(`Event ${e} published with arguments'`,...t)}));else h(this,r).addEvent(e,t)}subscribe(e,t,n={}){const{preventEventDraining:o,ignoreQueuedEvents:a}=n;if(!h(this,i)[e])h(this,i)[e]=[];if(h(this,r).hasDelayedEvents(e)&&!a)if(o)h(this,r).getEvents(e).forEach((e=>t(...e)));else h(this,r).drainEvents(e).forEach((e=>t(...e)));h(this,i)[e].push(t)}unsubscribe(e,t){var r;const n=null==(r=h(this,i)[e])?void 0:r.indexOf(t);if(n>-1)h(this,i)[e].splice(n,1)}removeListeners(e){delete h(this,i)[e]}};var z=(e=>(e["DeviceType"]="debug_device_type",e["Location"]="debug_location",e["VisitUrlPath"]="debug_visit_url_path",e["BrowserStorageLastActivityDate"]="debug_browser_storage_last_activity_date",e["NewVisitor"]="debug_new_visitor",e["HasUserVisitPage"]="debug_has_user_visit_page",e["Events"]="debug_events",e))(z||{});function B(){const e=e=>{const t=sessionStorage.getItem(e);if(t){if([z.DeviceType,z.VisitUrlPath,z.Location].includes(e))return t;if(e===z.BrowserStorageLastActivityDate){const e=new Date(t);return isNaN(e.getTime())?void 0:e}if([z.NewVisitor,z.HasUserVisitPage,z.Events].includes(e))try{return JSON.parse(t)}catch(i){F.error(`Invalid debug data for: ${e}`)}}};return{enabled:true,data:{[z.DeviceType]:e(z.DeviceType),[z.BrowserStorageLastActivityDate]:e(z.BrowserStorageLastActivityDate),[z.Location]:e(z.Location),[z.NewVisitor]:e(z.NewVisitor),[z.VisitUrlPath]:e(z.VisitUrlPath),[z.HasUserVisitPage]:e(z.HasUserVisitPage),[z.Events]:e(z.Events)}}}n=new WeakMap;const M=new class{constructor(){w(this,n,{[p.LikeItem]:[],[p.OrderPlaced]:[],[p.UnlikeItem]:[],[p.ViewCategory]:[],[p.ViewItem]:[],[p.WishlistItem]:[],[p.PageVisit]:[],[p.Popup]:[],[p.Cart]:[]})}getEvents(e){return Promise.resolve(h(this,n)[e])}getAllEvents(){return Promise.resolve(Object.values(h(this,n)).flat(1))}getAllECommerceEvents(){return Promise.resolve([...h(this,n)[p.ViewItem],...h(this,n)[p.ViewCategory],...h(this,n)[p.LikeItem],...h(this,n)[p.UnlikeItem],...h(this,n)[p.WishlistItem],...h(this,n)[p.OrderPlaced],...h(this,n)[p.Cart]])}getAllPopupEvents(){return Promise.resolve([...h(this,n)[p.Popup]])}saveEvent(e){return h(this,n)[e.eventType].push(e),Promise.resolve()}};var j=(e=>(e["v2"]="v2",e["af"]="af",e["wp"]="wp",e["we"]="we",e["ec"]="ec",e))(j||{}),J=(e=>(e["v2"]="GRV2",e["af"]="GRAF",e["wp"]="GRWP",e["we"]="GRWE",e["ec"]="GREC",e))(J||{});const G={[j.af]:"autoFunnel",[j.ec]:"ecommerce",[j.v2]:"tracking",[j.we]:"webEvents",[j.wp]:"webPush"};o=new WeakSet,a=e=>G[e];const q=new class{constructor(){w(this,o)}setScriptInitialized(e){const t=f(this,o,a).call(this,e);window.__grIntegrationConfig[t].isModuleInitialized=true}isScriptInitialized(e){var t,i;const r=f(this,o,a).call(this,e);return(null==(i=null==(t=null==window?void 0:window.__grIntegrationConfig)?void 0:t[r])?void 0:i.isModuleInitialized)??false}},H=new class{constructor(){this.scriptModuleManager=q}initialize(e){const{xsid:t,grid:i,clientLatestGrid:r,domain:n,aid:o,useNOStorage:a,useBetterSubscriberIdentification:s,isServedFromCustomDomain:d,scriptsDomain:c,scriptsVersion:l,tracking:u,isDebugMode:g,uuuid:p}=e;if(g)x.startDebug();window.__grIntegrationConfig=window.__grIntegrationConfig||{cData:{aid:o,grid:i,domain:n,useNOStorage:a,useBetterSubscriberIdentification:s,isServedFromCustomDomain:d,clientLatestGrid:r,uuuid:p},visitor:{email:null,eComId:null,xsid:t},tracking:{isModuleInitialized:false,isEnabled:u},webEvents:{isModuleInitialized:false,visitorApplicationEndpoint:null,automationJourneyGraphs:{},webPushActivePromptGraph:null,popupGraphs:{}},webPush:{isModuleInitialized:false,customSwPath:null,wpid:null,pushDomain:null,promptEndpoint:null},analyticsData:{scriptsDomain:c,scriptsVersion:l},ecommerce:{isModuleInitialized:false},autoFunnel:{isModuleInitialized:false},eventBus:R,temporaryEventsStorage:M,debug:g?B():void 0,delayedScripts:{},scriptTypesInitialized:new Set}}canUseBackendForSubscriberIdentification(){return window.__grIntegrationConfig.cData.useBetterSubscriberIdentification}getUserAid(){return window.__grIntegrationConfig.cData.aid}getClientLatestGrid(){return window.__grIntegrationConfig.cData.clientLatestGrid}getUserAnalyticsDomain(){return window.__grIntegrationConfig.cData.domain}getUserUuid(){return window.__grIntegrationConfig.cData.uuuid}enablePopupDevMode(){window.__grIntegrationConfig.setCustomPopupRendererUrl=e=>{window.sessionStorage.setItem(L.PopupsRendererCustomUrl,e)}}getPopupRendererCustomUrl(){return window.sessionStorage.getItem(L.PopupsRendererCustomUrl)}setCustomSwPath(e){if("string"!=typeof e)throw new Error("Path type must be string");if(!e.match(/gr_sw_main.js|service-worker\/service-worker.js$/))throw new Error("Invalid sw file name");window.__grIntegrationConfig.webPush.customSwPath=e}getCustomSwPath(){var e;return null==(e=window.__grIntegrationConfig)?void 0:e.webPush.customSwPath}isTrackingEnabled(){return window.__grIntegrationConfig.tracking.isEnabled}isTrackingScriptServedFromCustomDomain(){return window.__grIntegrationConfig.cData.isServedFromCustomDomain}set visitorEmail(e){window.__grIntegrationConfig.visitor.email=e}get visitorEmail(){return window.__grIntegrationConfig.visitor.email}get pushWpid(){return window.__grIntegrationConfig.webPush.wpid}set pushWpid(e){window.__grIntegrationConfig.webPush.wpid=e}set pushDomain(e){window.__grIntegrationConfig.webPush.pushDomain=e}get pushDomain(){return window.__grIntegrationConfig.webPush.pushDomain}set pushPromptEndpoint(e){window.__grIntegrationConfig.webPush.promptEndpoint=e}get pushPromptEndpoint(){return window.__grIntegrationConfig.webPush.promptEndpoint}get eventBus(){return window.__grIntegrationConfig.eventBus}get canUseBackendStorageForEvents(){return window.__grIntegrationConfig.cData.useNOStorage}get webConnectScriptCdnUrl(){return window.__grIntegrationConfig.analyticsData.scriptsDomain}get webConnectCurrentScriptsVersion(){return window.__grIntegrationConfig.analyticsData.scriptsVersion}get isDebug(){var e,t;return!!(null==(t=null==(e=window.__grIntegrationConfig)?void 0:e.debug)?void 0:t.enabled)}set debugObject(e){window.__grIntegrationConfig.debug=e}get debugObject(){var e;return null==(e=window.__grIntegrationConfig)?void 0:e.debug}get delayedScripts(){var e;return(null==(e=window.__grIntegrationConfig)?void 0:e.delayedScripts)||{}}set delayedScripts(e){window.__grIntegrationConfig.delayedScripts=e}set visitorApplicationEndpoint(e){window.__grIntegrationConfig.webEvents.visitorApplicationEndpoint=e}get visitorApplicationEndpoint(){return window.__grIntegrationConfig.webEvents.visitorApplicationEndpoint}get userEventsStorageApplicationUrl(){return window.__grIntegrationConfig.ecommerce.webEventsSearchApplicationEndpoint}set userEventsStorageApplicationUrl(e){window.__grIntegrationConfig.ecommerce.webEventsSearchApplicationEndpoint=e}get temporaryEventsStorage(){return window.__grIntegrationConfig.temporaryEventsStorage}get automationJourneyGraphs(){return window.__grIntegrationConfig.webEvents.automationJourneyGraphs}get webPushActivePromptGraph(){return window.__grIntegrationConfig.webEvents.webPushActivePromptGraph}set webPushActivePromptGraph(e){window.__grIntegrationConfig.webEvents.webPushActivePromptGraph=e}get popupGraphs(){return window.__grIntegrationConfig.webEvents.popupGraphs}get visitorXsid(){return window.__grIntegrationConfig.visitor.xsid}};var $=(e=>(e["Show"]="show",e["Close"]="close",e["Submit"]="submit",e))($||{}),X=(e=>(e["One"]="1.0",e))(X||{}),Z=(e=>(e["Web"]="web",e["Mobile"]="mobile",e))(Z||{});if(false){if("undefined"!=typeof navigator&&"ReactNative"===navigator.product&&"undefined"==typeof crypto)throw new Error("React Native does not have a built-in secure random generator. If you don’t need unpredictable IDs use `nanoid/non-secure`. For secure IDs, import `react-native-get-random-values` before Nano ID.");if("undefined"!=typeof msCrypto&&"undefined"==typeof crypto)throw new Error("Import file with `if (!window.crypto) window.crypto = window.msCrypto` before importing Nano ID to fix IE 11 support");if("undefined"==typeof crypto)throw new Error("Your browser does not have secure random generator. If you don’t need unpredictable IDs, you can use nanoid/non-secure.")}function Q(e){const t=document.cookie.match(new RegExp(`(^| )${e}=([^;]+)`));if(t)return t[2]}var Y=(e=>(e["visitorUuid"]="gaVisitorUuid",e["visitorValuable"]="gaIsValuable",e["VisitorEmail"]="gaVisitorEId",e["VisitorResubscribed"]="gaVisitorResubscribed",e["NotificationConsentAcceptedFromPrompt"]="gaWpnConAcc",e["NotificationConsentCustomPromptRejectedDEPRECATED"]="gaWpnConRej-{promptId}",e["NotificationConsentCustomPromptRejected"]="gaWpnConRej-promptId",e))(Y||{});const K=new class{constructor(){this.timer=Date.now()}getCurrentVisitOnPageTime(){return Date.now()-this.timer}};var ee,te,ie,re,ne,oe,ae,se,de,ce,le,ue,ge,pe,ve,me,he,we,ye,fe,Ie,Ce,be,Ee,Se,Pe,_e,De,Te,Ve,ke,Ae,Oe,Ue,Le,Ne,xe,Fe,We,Re;(Re=ee||(ee={}))["ShowWhenCondition"]="showWhenCondition",Re["VisitorsCondition"]="visitors",Re["DeviceCondition"]="device",Re["LocationCondition"]="location",Re["ECommerceCondition"]="ecommerce",Re["TriggerFrequency"]="frequency",Re["PreventDisplay"]="preventDisplay",void(Re["DateRange"]="dateRange"),(We=te||(te={}))["Mobile"]="mobile",We["Tablet"]="tablet",void(We["Desktop"]="desktop"),(Fe=ie||(ie={}))["All"]="all",Fe["New"]="new",void(Fe["Returning"]="returning"),void((re||(re={}))["All"]="all"),(xe=ne||(ne={}))["ConditionsLogicSeparator"]="conditionsLogicSeparator",void(xe["ECommerceConditions"]="ecommerceConditions"),(Ne=oe||(oe={}))["Amount"]="amount",void(Ne["Date"]="date"),(Le=ae||(ae={}))["And"]="and",void(Le["Or"]="or"),(Ue=se||(se={}))["Exactly"]="exactly",Ue["LessThan"]="lessThan",void(Ue["MoreThan"]="moreThan"),(Oe=de||(de={}))["LastDays"]="lastDays",void(Oe["DateRange"]="dateRange"),(Ae=ce||(ce={}))["AnyProduct"]="any",Ae["AnyCategory"]="any",Ae["AnyProductLiked"]="any",Ae["AnyProductInPlacedOrder"]="any",Ae["AnyCategoryInPlacedOrder"]="any",Ae["AnyProductInUpdatedCart"]="any",void(Ae["AnyCategoryInUpdatedCart"]="any"),(ke=le||(le={}))["PastEvents"]="filter",void(ke["FutureEvents"]="await"),(Ve=ue||(ue={}))["Category"]="category",void(Ve["Product"]="product"),void((ge||(ge={}))["Product"]="product"),(Te=pe||(pe={}))["ViewProductOrCategory"]="productOrCategoryView",Te["LikeProduct"]="likeItem",Te["OrderPlaced"]="orderPlaced",void(Te["CartUpdated"]="cartUpdated"),(De=ve||(ve={}))["Percent"]="percent",void(De["Selector"]="selector"),(_e=me||(me={}))["Instantly"]="instantly",_e["Delay"]="delay",_e["Exit"]="exit",_e["Scroll"]="scroll",_e["Inactivity"]="inactivity",void(_e["Click"]="click"),(Pe=he||(he={}))["AfterSubmit"]="submit",Pe["AfterClose"]="close",void(Pe["AfterTimes"]="timesAmount"),(Se=we||(we={}))["Always"]="always",Se["Session"]="session",void(Se["EveryDays"]="everyDays"),(Ee=ye||(ye={}))["Exactly"]="equal",Ee["LessThan"]="lessThan",void(Ee["MoreThan"]="moreThan"),(be=fe||(fe={}))["Exactly"]="equal",be["LessThan"]="lessThan",void(be["MoreThan"]="moreThan"),(Ce=Ie||(Ie={}))[Ce["InvalidCssSelector"]=1]="InvalidCssSelector",Ce[Ce["EmptyCssSelector"]=2]="EmptyCssSelector",Ce[Ce["CssSelectorTooLong"]=3]="CssSelectorTooLong",Ce[Ce["CssInvalidType"]=4]="CssInvalidType",Ce[Ce["InvalidTimeoutProperty"]=5]="InvalidTimeoutProperty",Ce[Ce["ShowWhenScrollPercentInvalidValueType"]=6]="ShowWhenScrollPercentInvalidValueType",Ce[Ce["ShowWhenScrollPercentValueOutOfBound"]=7]="ShowWhenScrollPercentValueOutOfBound",Ce[Ce["VisitorTriggerEmpty"]=8]="VisitorTriggerEmpty",Ce[Ce["VisitorTriggerInvalidProperty"]=9]="VisitorTriggerInvalidProperty",Ce[Ce["DevicesTriggerEmpty"]=10]="DevicesTriggerEmpty",Ce[Ce["DevicesTriggerInvalidValue"]=11]="DevicesTriggerInvalidValue",Ce[Ce["FrequencyEmptyTrigger"]=12]="FrequencyEmptyTrigger",Ce[Ce["FrequencyTriggerInvalidName"]=13]="FrequencyTriggerInvalidName",Ce[Ce["FrequencyTriggerNDaysInvalidPropertyValue"]=14]="FrequencyTriggerNDaysInvalidPropertyValue",Ce[Ce["FrequencyTriggerNDaysEmptyValue"]=15]="FrequencyTriggerNDaysEmptyValue",Ce[Ce["PreventDisplayTriggerInvalidName"]=16]="PreventDisplayTriggerInvalidName",Ce[Ce["PreventDisplayTriggerAfterTimesNoValue"]=17]="PreventDisplayTriggerAfterTimesNoValue",Ce[Ce["PreventDisplayTriggerAfterTimesInvalidValue"]=18]="PreventDisplayTriggerAfterTimesInvalidValue",Ce[Ce["DateRangeInvalidFromDate"]=19]="DateRangeInvalidFromDate",Ce[Ce["DateRangeInvalidToDate"]=20]="DateRangeInvalidToDate",Ce[Ce["DateRangeDateFromAfterDateTo"]=21]="DateRangeDateFromAfterDateTo",Ce[Ce["LocationEmptyTrigger"]=22]="LocationEmptyTrigger",Ce[Ce["LocationInvalidType"]=23]="LocationInvalidType",Ce[Ce["LackOfLogicSeparator"]=24]="LackOfLogicSeparator",Ce[Ce["LackOfTriggerConditions"]=25]="LackOfTriggerConditions",Ce[Ce["InvalidTriggerConditions"]=26]="InvalidTriggerConditions",Ce[Ce["NoProductOrCategorySelected"]=27]="NoProductOrCategorySelected",Ce[Ce["ProductInvalidType"]=28]="ProductInvalidType",Ce[Ce["CategoryInvalidType"]=29]="CategoryInvalidType",Ce[Ce["AmountInvalidConditionName"]=30]="AmountInvalidConditionName",Ce[Ce["AmountInvalidConditionValueType"]=31]="AmountInvalidConditionValueType",Ce[Ce["DateInvalidConditionName"]=32]="DateInvalidConditionName",Ce[Ce["DateLastDaysInvalidConditionValue"]=33]="DateLastDaysInvalidConditionValue",Ce[Ce["DateDateRangeInvalidConditionValue"]=34]="DateDateRangeInvalidConditionValue",Ce[Ce["DateDateRangeFromInvalidValue"]=35]="DateDateRangeFromInvalidValue",Ce[Ce["DateDateRangeToInvalidValue"]=36]="DateDateRangeToInvalidValue",Ce[Ce["DateDateRangeDateFromAfterDateTo"]=37]="DateDateRangeDateFromAfterDateTo",Ce[Ce["PopupTriggerInvalidName"]=38]="PopupTriggerInvalidName",Ce[Ce["PopupTriggerLackOfValuesInLikeItemTrigger"]=39]="PopupTriggerLackOfValuesInLikeItemTrigger",Ce[Ce["PopupTriggerLikeItemInvalidValues"]=40]="PopupTriggerLikeItemInvalidValues",Ce[Ce["PopupTriggerOrderPlacedNoConditions"]=41]="PopupTriggerOrderPlacedNoConditions",Ce[Ce["PopupTriggerOrderPlacedInvalidProducts"]=42]="PopupTriggerOrderPlacedInvalidProducts",Ce[Ce["PopupTriggerOrderPlacedInvalidCategories"]=43]="PopupTriggerOrderPlacedInvalidCategories",Ce[Ce["PopupTriggerCartUpdatedNoConditions"]=44]="PopupTriggerCartUpdatedNoConditions",Ce[Ce["PopupTriggerCartUpdatedInvalidProducts"]=45]="PopupTriggerCartUpdatedInvalidProducts",Ce[Ce["PopupTriggerCartUpdatedInvalidCategories"]=46]="PopupTriggerCartUpdatedInvalidCategories",Ce[Ce["PopupTriggerPriceValueConditionInvalidComparator"]=47]="PopupTriggerPriceValueConditionInvalidComparator",Ce[Ce["PopupTriggerPriceValueConditionInvalidValue"]=48]="PopupTriggerPriceValueConditionInvalidValue",Ce[Ce["PopupTriggerProductsAmountValueConditionInvalidComparator"]=49]="PopupTriggerProductsAmountValueConditionInvalidComparator",Ce[Ce["PopupTriggerProductsAmountValueConditionInvalidValue"]=50]="PopupTriggerProductsAmountValueConditionInvalidValue",void(Ce[Ce["PopupTriggerInvalidTriggerType"]=51]="PopupTriggerInvalidTriggerType");var ze=(e=>(e[e["Mobile"]=480]="Mobile",e[e["Tablet"]=768]="Tablet",e))(ze||{});const Be=Symbol("DeviceService");class Me{constructor(e){if(new.target===Me&&e!==Be)throw new Error(`Invalid ${new.target.name} constructor`)}detectDeviceTypeByScreenWidth(e){var t;const{availWidth:i,availHeight:r}=screen;let n=null==(t=screen.orientation)?void 0:t.type;if(!n)n=window.matchMedia("(orientation: landscape)").matches?"landscape":"portrait";const o=n.match(/landscape/)?r:i;if(ze.Mobile>=o)return te.Mobile;else if(o>ze.Mobile&&ze.Tablet>=o)return te.Tablet;return e?te.Tablet:te.Desktop}isDesktopDevice(){return this.getDeviceType()===te.Desktop}getDeviceType(){const{userAgentData:e}=window.navigator;if(e){const{mobile:t}=e;if(t)return this.detectDeviceTypeByScreenWidth(true);else return te.Desktop}return this.detectDeviceTypeByScreenWidth()}getBrowserLanguage(){const{language:e}=window.navigator;if(e.match(/\w{2}-\w{2}/))return e.split("-")[0].toLowerCase();else return e.toLowerCase()}getUserOs(){const{userAgentData:e}=window.navigator;if(e)return e.platform.toLowerCase();else return this.getOsFromUserAgent()}getOsFromUserAgent(){let e="unknown";const{userAgent:t}=navigator,i=t.toLowerCase();if(i.includes("win"))e="windows";if(i.includes("mac"))e="macos";if(i.includes("x11"))e="unix";if(i.includes("linux"))e="Linux";if(i.includes("android"))e="android";if(/iphone|ipad|ipod/.test(i))e="ios";return e}}const je=new Me(Be),Je=new class{encodeEmail(e){return btoa(e)}decode(e){return atob(e)}isEncodedString(e){try{return atob(e),true}catch{return false}}validateEmail(e){return/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/.test(e)}};class Ge extends Error{constructor(e){super(e)}static create(...[e,t]){switch(e){case"email":return new Ge(`Provided string ${t} is not valid email address`);default:void F.error(`Unsupported value: ${e}`)}}}class qe{constructor({e}={}){if(e)this.e=Je.encodeEmail(e)}static createFromContextData(e){try{if(Je.isEncodedString(e.e))e.e=Je.decode(e.e);return qe.validate(e),new qe(e)}catch(t){if(t instanceof Ge)return F.error(t),qe.createBlank();throw t}}static createBlank(){return new qe}static validate(e){if("e"in e&&!Je.validateEmail(e.e))throw Ge.create("email",e.e)}toJSON(){return{...this}}}class He{constructor(e){w(this,s,void 0),this.eventType=e,y(this,s,null),this.eventId=null,this.aid=H.getUserAid(),this.grid=H.getClientLatestGrid(),this.time=K.getCurrentVisitOnPageTime(),this.context=qe.createBlank(),this.uuid=Q(Y.visitorUuid),this.url=window.location.href,this.occurredOn=new Date,this.tags=[]}get externalUid(){return h(this,s)}toJSON(){return{eventId:this.eventId,aid:this.aid,grid:this.aid,uuid:this.uuid,externalUid:this.externalUid,context:this.context.toJSON(),time:this.time,url:this.url,tags:this.tags,eventType:this.eventType,occurredOn:this.occurredOn.toUTCString()}}toString({normalized:e}={}){if(e)return JSON.stringify(this.normalizeForExternalStorage());else return JSON.stringify(this.toJSON())}normalize(){const{eventId:e,...t}=this.toJSON();return t}getBaseNormalizedEvent(){return{version:X.One,user_uuid:H.getUserUuid(),time:this.time,tags:this.tags,occurred_on:this.occurredOn.toISOString(),url:this.url,app:{lang:je.getBrowserLanguage(),device:je.getDeviceType(),os:je.getUserOs()},channel:Z.Web,visitor:{uuid:this.uuid,external_id:this.externalUid,xsid:H.visitorXsid}}}}s=new WeakMap;class $e extends He{constructor(e,t,i=qe.createBlank()){super(p.Popup),this.popupEvent=e,this.popupId=t,this.context=i}toJSON(){return{...super.toJSON(),popupId:this.popupId,popupEvent:this.popupEvent}}normalizeForExternalStorage(){return{...this.getBaseNormalizedEvent(),event:{version:"1.0",name:p.Popup}}}}class Xe extends He{toJSON(){return{...super.toJSON(),data:this.data}}normalizeForExternalStorage(){const e=this.getBaseNormalizedEvent();return{...e,event:{version:this.eventVersion,name:this.eventType,data:this.data},visitor:{uuid:e.visitor.uuid,external_id:e.visitor.external_id}}}}class Ze extends He{constructor(e){super(p.ShopifyAbandonedCart),this.data=e}toJSON(){return{...super.toJSON(),data:this.data}}normalizeForExternalStorage(){return{...this.getBaseNormalizedEvent(),event:{version:"1.0",name:p.ShopifyAbandonedCart,data:this.data}}}}const Qe=class e{constructor(e){w(this,d,void 0),y(this,d,e)}static create(t){return new e(t)}validate(e){return Object.entries(h(this,d)).reduce(((t,[i,r])=>{if(false===t)return t;if(null==e[i]&&r._isOptional)return t;else return r.call(e,e[i])}),true)}stringifySchemaShape(){var t;return f(t=e,c,l).call(t,h(this,d))}trim(e,t=h(this,d)){var i;const r={};for(const[n,o]of Object.entries(e))if("object"==typeof o&&null!==o){if(n in t){const e=null==(i=t[n])?void 0:i.valueShape;if(Array.isArray(o))if(e)r[n]=o.map((t=>this.trim(t,e)));else r[n]=o;else r[n]=this.trim(o,e)}}else if(n in t)r[n]=o;return r}static string(){return Ke((e=>"string"==typeof e),(()=>"string"))}static number(){return Ke((e=>"number"==typeof e),(()=>"number"))}static boolean(){return Ke((e=>"boolean"==typeof e),(()=>"boolean"))}static dateString(){return Ke((e=>{if("string"!=typeof e)return false;else return!Number.isNaN(new Date(e).getTime())}),(()=>"date string"))}static object(t){return Ke((i=>{if(!t||"object"!=typeof t)return false;else return e.create(t).validate(i)}),(()=>f(this,c,l).call(this,t)),t)}static array(t){return Ke((i=>{if(!Array.isArray(i))return false;if("function"==typeof t)return i.every((e=>t(e)));const r=e.create(t);return i.every((e=>r.validate(e)))}),(()=>`[${f(this,c,l).call(this,t)}]`),"function"==typeof t?void 0:t)}};d=new WeakMap,c=new WeakSet,l=e=>{const t={};if("function"==typeof e)return e.getValueType();else for(const[i,r]of Object.entries(e))t[i]=r.getValueType();try{return JSON.stringify(t).replaceAll('\\"','"')}catch{return"Failed to parse validation shape"}},w(Qe,c);let Ye=Qe;function Ke(e,t,i){if(e.optional=()=>(e._isOptional=true,e),e.getValueType=t,i)e.valueShape=i;return e}const et={id:Ye.string(),sku:Ye.string().optional(),name:Ye.string().optional(),vendor:Ye.string().optional(),price:Ye.string().optional(),currency:Ye.string().optional()},tt=Ye.array({id:Ye.string(),name:Ye.string().optional()}).optional(),it={id:Ye.string()},rt={shop:Ye.object({...it}).optional(),product:Ye.object({...et}),categories:tt},nt={product:Ye.object({...et}),categories:tt,quantity:Ye.number()},ot=Ye.create({...rt}),at=Ye.create({shop:Ye.object({...it}).optional(),id:Ye.string(),name:Ye.string().optional()}),st=Ye.create({...rt}),dt=Ye.create({...rt}),ct=Ye.create({...rt}),lt=Ye.create({orderId:Ye.string(),cartId:Ye.string().optional(),price:Ye.number(),currency:Ye.string(),products:Ye.array(nt)}),ut=Ye.create({price:Ye.number(),cartId:Ye.string(),cartUrl:Ye.string(),currency:Ye.string(),products:Ye.array(nt)});class gt extends Error{constructor(e){super(`Data doesn't match required schema: ${e}`)}}class pt extends He{constructor(e=qe.createBlank()){super(p.PageVisit),this.context=e}normalizeForExternalStorage(){return{...this.getBaseNormalizedEvent(),event:{version:"1.0",name:this.eventType}}}}const vt={[p.ViewItem]:ot,[p.ViewCategory]:at,[p.WishlistItem]:st,[p.LikeItem]:dt,[p.UnlikeItem]:ct,[p.OrderPlaced]:lt,[p.Cart]:ut},mt={[p.ViewItem]:class extends Xe{constructor(e,t){super(p.ViewItem),this.data=e,this.context=t,this.eventVersion="1.0"}normalizeForExternalStorage(){const e=super.normalizeForExternalStorage();return e.event.data.product.price=parseFloat(e.event.data.product.price),e.time=K.getCurrentVisitOnPageTime(),e}},[p.ViewCategory]:class extends Xe{constructor(e,t){super(p.ViewCategory),this.data=e,this.context=t,this.eventVersion="1.0"}normalizeForExternalStorage(){const e=super.normalizeForExternalStorage();return e.time=K.getCurrentVisitOnPageTime(),e}},[p.WishlistItem]:class extends Xe{constructor(e,t){super(p.WishlistItem),this.data=e,this.context=t,this.eventVersion="1.0"}},[p.LikeItem]:class extends Xe{constructor(e,t){super(p.LikeItem),this.data=e,this.context=t,this.eventVersion="1.0"}normalizeForExternalStorage(){const e=super.normalizeForExternalStorage();return e.event.data.product.price=parseFloat(e.event.data.product.price),e}},[p.UnlikeItem]:class extends Xe{constructor(e,t){super(p.UnlikeItem),this.data=e,this.context=t,this.eventVersion="1.0"}normalizeForExternalStorage(){const e=super.normalizeForExternalStorage();return e.event.data.product.price=parseFloat(e.event.data.product.price),e}},[p.OrderPlaced]:class extends Xe{constructor(e,t){super(p.OrderPlaced),this.data=e,this.context=t,this.eventVersion="1.0"}normalizeForExternalStorage(){const e=super.normalizeForExternalStorage();return e.event.data.products=e.event.data.products.map((e=>({...e,product:{...e.product,price:parseFloat(e.product.price)}}))),e}},[p.Cart]:class extends Xe{constructor(e,t){super(p.Cart),this.data=e,this.context=t,this.eventVersion="1.0"}normalizeForExternalStorage(){const e=super.normalizeForExternalStorage();return e.event.data.products=e.event.data.products.map((e=>({...e,product:{...e.product,price:parseFloat(e.product.price)}}))),e}}},ht=class e{static getPageVisitEvent(){return new pt}static getPopupEvent({popupId:e,popupEventName:t}){return new $e(t,e)}static getPopupSubmitEvent(e){return new $e($.Submit,e)}static getPopupShowEvent(e){return new $e($.Show,e)}static getPopupCloseEvent(e){return new $e($.Close,e)}static getViewItemEvent(t,i){var r;return f(r=e,u,g).call(r,p.ViewItem,t,i)}static getWishlistItemEvent(t,i){var r;return f(r=e,u,g).call(r,p.WishlistItem,t,i)}static getLikeItemEvent(t,i){var r;return f(r=e,u,g).call(r,p.LikeItem,t,i)}static getUnlikeItemEvent(t,i){var r;return f(r=e,u,g).call(r,p.UnlikeItem,t,i)}static getViewCategoryEvent(t,i){var r;return f(r=e,u,g).call(r,p.ViewCategory,t,i)}static getOrderPlacedEvent(t,i){var r;return f(r=e,u,g).call(r,p.OrderPlaced,t,i)}static getCartUpdateEvent(t,i){var r;return f(r=e,u,g).call(r,p.Cart,t,i)}static getShopifyIntegrationAbandonedCartEvent(e){try{return(e=>{if("object"!=typeof e||null===e)throw new b("Invalid data parameter type");else{const t=Object.entries(E),i=Object.keys(e);if(!S.every((e=>i.includes(e))))throw new b("Lack of required parameters");if(!t.every((([t,i])=>!e[t]||typeof e[t]===i)))throw new b("Properties have invalid type")}return true})(e),new Ze((t=e,i=Object.keys(E),Object.entries(t).reduce(((e,[t,r])=>{if(i.includes(t))e[t]=r;return e}),{})))}catch(r){return F.error(r),null}var t,i}};u=new WeakSet,g=(e,t,i)=>{const r=vt[e],n=mt[e];if(!r||!n)throw new Error("Event type not supported in event factory");if(!r.validate(t))throw new gt(r.stringifySchemaShape());return new n(r.trim(t),i)},w(ht,u);let wt=ht;const yt=new class{sendShopifyWebhookAbandonedCartEvent(e){(class{static sendJSON(e,t,i=true){const r=i?JSON.stringify({...JSON.parse(t),[D.UserAid]:H.getUserAid()}):t;navigator.sendBeacon(e,new Blob([r],{type:"application/json"}))}}).sendJSON(new URL("activity/abandoned-cart",H.getUserAnalyticsDomain()).href,JSON.stringify({...e.toJSON(),isUuidValuable:!!Q(Y.visitorValuable)}))}};class ft{constructor(){this.onECommerceShopifyAbandonedCart=e=>{const t=wt.getShopifyIntegrationAbandonedCartEvent(e);yt.sendShopifyWebhookAbandonedCartEvent(t)}}static getInstance(){return new ft}initialize(){H.eventBus.subscribe(I.ShopifyAbandonedCart,this.onECommerceShopifyAbandonedCart)}}const It=new class{isScriptDelayed(e){return Object.keys(H.delayedScripts).includes(e)}delay(e){if(!this.isScriptDelayed(e))H.delayedScripts={...H.delayedScripts,[e]:void 0}}storeDelayedScriptParams(e,t){if(this.isScriptDelayed(e))H.delayedScripts={...H.delayedScripts,[e]:t}}initScript(e){var t;const i=H.delayedScripts[e];if(i){H.delayedScripts=Object.fromEntries(Object.entries(H.delayedScripts).filter((([t])=>t!==e)));const r=J[e];null==(t=null==window?void 0:window[r])?void 0:t.init(...i)}}},Ct=new class{constructor(){this.eCommerceShopify=new ft,this.onViewItemEvent=(e,t={})=>{this.handleECommerceItemEvent(p.ViewItem,e,t)},this.onWishlistItemEvent=(e,t={})=>{this.handleECommerceItemEvent(p.WishlistItem,e,t,false)},this.onLikeItemEvent=(e,t={})=>{this.handleECommerceItemEvent(p.LikeItem,e,t)},this.onUnlikeItemEvent=(e,t={})=>{this.handleECommerceItemEvent(p.UnlikeItem,e,t)},this.onViewCategoryEvent=(e,t={})=>{this.handleECommerceItemEvent(p.ViewCategory,e,t)},this.onPurchaseItemsEvent=(e,t={})=>{this.handleECommerceItemEvent(p.OrderPlaced,e,t)},this.onCartUpdateEvent=(e,t={})=>{this.handleECommerceItemEvent(p.Cart,e,t)}}initialize(){this.eCommerceShopify.initialize(),this.attachEvents()}attachEvents(){H.eventBus.subscribe(I.ViewItem,this.onViewItemEvent),H.eventBus.subscribe(I.ViewCategory,this.onViewCategoryEvent),H.eventBus.subscribe(I.WishListItem,this.onWishlistItemEvent),H.eventBus.subscribe(I.LikeItem,this.onLikeItemEvent),H.eventBus.subscribe(I.UnlikeItem,this.onUnlikeItemEvent),H.eventBus.subscribe(I.Purchase,this.onPurchaseItemsEvent),H.eventBus.subscribe(I.CartUpdate,this.onCartUpdateEvent)}handleECommerceItemEvent(e,t,i,r=true){H.eventBus.publish(I.SaveEvent,{sendToBackend:r},qe.createFromContextData(i),e,t)}};e.init=(e="{}")=>{if(H.scriptModuleManager.isScriptInitialized(j.ec))return;H.scriptModuleManager.setScriptInitialized(j.ec);const{userEventsStorageApplicationEndpoint:t}=JSON.parse(e);if(t)H.userEventsStorageApplicationUrl=t;if(It.isScriptDelayed(j.ec))return It.storeDelayedScriptParams(j.ec,[]),null;try{Ct.initialize()}catch(i){F.error("Error while initializing eCommerce script")}},Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}((e="undefined"!=typeof globalThis?globalThis:e||self).GREC={})}(this);